﻿using System;
using System.Collections.Generic;
using System.Text;
using AspNetCs.Model;
using AspNetCs.DALFactory;
using AspNetCs.IDAL;
using System.Data;

namespace AspNetCs.Bll
{
    public class Annouce
    {
        private IAnnounce announceDAL = Conn.CreateAnnounce();

        /// <summary>
        /// 提供Announce_Model对象，添加网站公告
        /// </summary>
        /// <param name="model">Announce_Model对象</param>
        /// <returns>返回添加网站公告的结果</returns>
        public bool addAnnounce(Announce_Model model)
        {
            int count = 0;
            count = announceDAL.Add(model);
            return count > 0 ? true : false;
        }

        /// <summary>
        /// 获得所有网站公告
        /// </summary>
        /// <returns></returns>
        public DataTable GetAnnounceList()
        {
            DataTable dataTable = new DataTable();
            dataTable = announceDAL.GetAnnounceList("");
            return dataTable;
        }

        /// <summary>
        /// 获得所有网站公告
        /// </summary>
        /// <returns></returns>
        public DataTable GetDataTable(string filter)
        {
            DataTable dataTable = new DataTable();
            dataTable = announceDAL.GetAnnounceList(filter);
            return dataTable;
        }


        /// <summary>
        /// 删除网站公告
        /// </summary>
        /// <param name="id">网站公告id</param>
        /// <returns></returns>
        public bool deleteAnnounce(int id)
        {
            int reCount = announceDAL.del(id);
            return reCount > 0 ? true : false;
        }

        /// <summary>
        /// 通过编号查询网站公告的详细信息
        /// </summary>
        /// <param name="id">网站公告id</param>
        /// <returns></returns>
        public Announce_Model getAnnouceById(int id)
        {
            return announceDAL.GetModel(id);
        }

        public bool updateAnnouce(Announce_Model model)
        {
            return announceDAL.update(model) > 0 ? true : false;
        }
    }
}
